import { App } from "vue";

export default (app: App<Element>) => {
    //控制可输入的下拉列表框最大输入长度
    //使用方法：v-select-max="5"
    app.directive("select-max", {
        mounted(el, binding, vnode) {
            if (el.tagName.toLowerCase() !== "input") {
                el = el.getElementsByTagName("input")[0];
            }

            if (!el.hasAttribute("maxLength")) {
                el.maxLength = binding.value;
            }
        },
    });
};
